package com.ucampus.controller;

import com.ucampus.entity.ResponseData;
import com.ucampus.entity.Shop;
import com.ucampus.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/shop")
public class ShopController {
    @Autowired
    private ShopService shopService;

    @GetMapping("/")
    public ResponseData getAll() {
        return shopService.getAll();
    }

    @GetMapping("/select")
    public ResponseData getByName(@RequestParam("name") String name) {
        return shopService.getByName(name);
    }

    @PostMapping("/upload")
    public ResponseData add(@RequestBody Shop shop){
        return shopService.add(shop.getName(),shop.getLocation(),shop.getMessage());
    }

    @PutMapping("/update")
    public ResponseData update(@RequestBody Shop shop){
        return shopService.update(shop.getId(),shop.getName(),shop.getLocation(),shop.getMessage());
    }

    @DeleteMapping("/delete")
    public ResponseData delete(@RequestBody List<Integer> list){
        return shopService.delete(list);
    }
}
